package com.billdimmick.merkabah;

import junit.framework.Assert;

import org.junit.Before;
import org.junit.Test;

public class TestSQSManagerWithSigning extends TestSQSManager {
	@Override
	@Before
	public void setUp() throws Exception {
		super.setUp();
		this.manager.getSecurity().setShouldSignMessages(true);
	}

	@Test
	public void testFailedValidate() throws SQSException {
		manager.createQueue("queue");
		manager.send("queue", "hello");
		SQSSecurityAdapter security=this.manager.getSecurity();
		Assert.assertTrue(security instanceof BasicSQSSecurityAdapter);
		BasicSQSSecurityAdapter basic=(BasicSQSSecurityAdapter)security;
		basic.evict();
		try {
			Message m=manager.receive("queue");
			Assert.fail("Expected a cryptographic failure");
		} catch (CryptographicFailureException fail) {
			Assert.assertEquals("VerifyFailed", fail.getExceptionCode());
			Assert.assertNull(fail.getRequestId());
		}
	}

}
